<?php
    header("content-type:text/html; charset=utf8");
    $con = mysqli_connect("localhost", "root", "guodong", "study");
    mysqli_set_charset($con, "utf8");
    
    $id = $_POST['id'];
    echo $id;

    if ($con) {
        $name = $_POST['name'];
        $age = $_POST['age'];
        $sex = $_POST['sex'];
        $class = $_POST['class'];

        $sql = "UPDATE stu SET `name`='$name', age='$age', sex='$sex', class='$class' WHERE id='$id'";
        $result = mysqli_query($con, $sql);

        if ($result > 0) {
            echo "修改成功！";
        } else {
            echo "修改失败！";
        }
    } else {
        echo "数据库连接失败！";
    }
